#ifndef ENTITY_H
#define ENTITY_H

#include "stdafx.h"
#include "RenderObject.h"
#include "Grid.h"
#include "Collider.h"

class Entity;
class EntityListener{
public:
	EntityListener(void){}
	virtual ~EntityListener(void){}

	virtual void RemoveEntity(Entity* entity) = 0;

protected:
};

enum EEntityType
{
	Basic_Tower,
	N64_Logo,
	Enemy_Type,
	Enemy_Spawner,
	Projectile_Type,
	Tree,
	Wall_Type,
	Enemy_Projectile,
	Slow_Tower,
	Slow_Projectile
};

class Entity
{
public:
	Entity(const EEntityType& entity_type) : m_collider(nullptr), m_listener(nullptr)
	{ 
		static unsigned int id_gen = 0;
		m_id = id_gen++;

		m_type = entity_type; 
		m_position = Vector3(0.0f, 0.0f, 0.0f); 
		m_rotation = Vector3(0.0f, 0.0f, 0.0f);
	};

	virtual ~Entity()
	{
		if (m_collider != nullptr)
			m_collider->Destroy();
	}

	virtual void Init(SceneObject* scene_object, Grid* grid) = 0;
	virtual void Update(float deltatime) = 0;
	void SetPosition(const Vector3& position) { m_position = position; };
	void SetRotation(const Vector3& rotation) { m_rotation = rotation; };
	unsigned int GetId() { return m_id; };
	SceneObject* GetSceneObject() const { return m_scene_object; };

	RenderObject* m_render_object;	//mikko was here
	int GetEntityType() const { return m_type; }
	Collider* GetCollider() const { return m_collider; }
	void SetCollider(Collider* collider) { m_collider = collider; }
	void SetEntityListener(EntityListener* listener) {m_listener = listener;}
	void RemoveMe() { m_listener->RemoveEntity(this); }
	const Vector3& GetPosition() const { return m_position; }

protected:
	SceneObject* m_scene_object;
	Collider* m_collider;

	Grid* m_grid;

	unsigned int m_id;

	Vector3 m_position;
	Vector3 m_rotation;
	EEntityType m_type;
	EntityListener* m_listener;
};

#endif